{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import seaborn as sns\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "to_train=pd.read_csv('input/train_time.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>label</th>\n",
       "      <th>college</th>\n",
       "      <th>rank</th>\n",
       "      <th>total_people</th>\n",
       "      <th>rank_percent</th>\n",
       "      <th>countM1</th>\n",
       "      <th>price_sumM1</th>\n",
       "      <th>price_avgM1</th>\n",
       "      <th>price_maxM1</th>\n",
       "      <th>...</th>\n",
       "      <th>地点263_avg</th>\n",
       "      <th>地点263_max</th>\n",
       "      <th>地点263_min</th>\n",
       "      <th>地点263_median</th>\n",
       "      <th>地点840_count</th>\n",
       "      <th>地点840_sum</th>\n",
       "      <th>地点840_avg</th>\n",
       "      <th>地点840_max</th>\n",
       "      <th>地点840_min</th>\n",
       "      <th>地点840_median</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2933.0</td>\n",
       "      <td>0.000341</td>\n",
       "      <td>49.0</td>\n",
       "      <td>201.31</td>\n",
       "      <td>4.108367</td>\n",
       "      <td>36.4</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2933.0</td>\n",
       "      <td>0.000682</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.00</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>117.0</td>\n",
       "      <td>6.157895</td>\n",
       "      <td>7.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>6.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>8</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1565.0</td>\n",
       "      <td>1572.0</td>\n",
       "      <td>0.995547</td>\n",
       "      <td>97.0</td>\n",
       "      <td>347.74</td>\n",
       "      <td>3.584948</td>\n",
       "      <td>10.0</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>9</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1570.0</td>\n",
       "      <td>1572.0</td>\n",
       "      <td>0.998728</td>\n",
       "      <td>98.0</td>\n",
       "      <td>491.01</td>\n",
       "      <td>5.010306</td>\n",
       "      <td>17.5</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2301.0</td>\n",
       "      <td>0.000435</td>\n",
       "      <td>27.0</td>\n",
       "      <td>82.96</td>\n",
       "      <td>3.072593</td>\n",
       "      <td>22.3</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>3.500000</td>\n",
       "      <td>4.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>3.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 432 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   id  label  college    rank  total_people  rank_percent  countM1  \\\n",
       "0   0    0.0      9.0     1.0        2933.0      0.000341     49.0   \n",
       "1   1    0.0      9.0     2.0        2933.0      0.000682     -1.0   \n",
       "2   8    0.0      6.0  1565.0        1572.0      0.995547     97.0   \n",
       "3   9    0.0      6.0  1570.0        1572.0      0.998728     98.0   \n",
       "4  10    0.0      3.0     1.0        2301.0      0.000435     27.0   \n",
       "\n",
       "   price_sumM1  price_avgM1  price_maxM1      ...       地点263_avg  地点263_max  \\\n",
       "0       201.31     4.108367         36.4      ...            -1.0       -1.0   \n",
       "1        -1.00    -1.000000         -1.0      ...            -1.0       -1.0   \n",
       "2       347.74     3.584948         10.0      ...            -1.0       -1.0   \n",
       "3       491.01     5.010306         17.5      ...            -1.0       -1.0   \n",
       "4        82.96     3.072593         22.3      ...            -1.0       -1.0   \n",
       "\n",
       "   地点263_min  地点263_median  地点840_count  地点840_sum  地点840_avg  地点840_max  \\\n",
       "0       -1.0          -1.0         -1.0       -1.0  -1.000000       -1.0   \n",
       "1       -1.0          -1.0         19.0      117.0   6.157895        7.0   \n",
       "2       -1.0          -1.0         -1.0       -1.0  -1.000000       -1.0   \n",
       "3       -1.0          -1.0         -1.0       -1.0  -1.000000       -1.0   \n",
       "4       -1.0          -1.0          2.0        7.0   3.500000        4.0   \n",
       "\n",
       "   地点840_min  地点840_median  \n",
       "0       -1.0          -1.0  \n",
       "1        4.0           6.0  \n",
       "2       -1.0          -1.0  \n",
       "3       -1.0          -1.0  \n",
       "4        3.0           3.5  \n",
       "\n",
       "[5 rows x 432 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "to_train.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.0       9325\n",
       "1000.0     741\n",
       "1500.0     465\n",
       "2000.0     354\n",
       "Name: label, dtype: int64"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "to_train['label'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.text.Text at 0x7f8330153950>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY8AAAEwCAYAAABPBv1HAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAA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yU8nswIqILuBZ4b2YeDlw2uF1mfgR4M9ALXB8Rx2RmAi8Gvgy8FvhOaw9Baozh\nITVJZt4FPBERfzXYFhEvAW5g81If0yhGKCsi4ukUYTEpIqZHxLnAf5ZzJv8AvCoi/hR4VWbeTjH5\n/uxyxCLVytNWUnMdB3w6In4M/IZiPaN3UMyHkJl9EfFV4IfAcuBiiquxjgKmAvdFRB/we4rlu/cC\nLi8X0psAXJSZ/WN6RNIIXNtKklSZw19JUmWGhySpMsNDklSZ4SFJqszwkCRVZnhIkiozPCRJlRke\nkqTK/h/ZlyWOw5A5WAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f83616ae910>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "count_classes = pd.value_counts(to_train['label'], sort = True).sort_index()\n",
    "count_classes.plot(kind = 'bar')\n",
    "plt.title(\"Class histogram\")\n",
    "plt.xlabel(\"Class\")\n",
    "plt.ylabel(\"Frequency\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X = to_train.ix[:, to_train.columns != 'label']\n",
    "y = to_train.ix[:, to_train.columns == 'label']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('Number transactions train dataset: ', 7619)\n",
      "('Number transactions test dataset: ', 3266)\n",
      "('Total number of transactions: ', 10885)\n"
     ]
    }
   ],
   "source": [
    "# 这里的采样方式，会造成数据分布变化 // resample to all data\n",
    "\n",
    "from sklearn.cross_validation import train_test_split\n",
    "\n",
    "# Whole dataset\n",
    "X_train, X_test, y_train, y_test = train_test_split(X,y,test_size = 0.3, random_state = 2017)\n",
    "\n",
    "print(\"Number transactions train dataset: \", len(X_train))\n",
    "print(\"Number transactions test dataset: \", len(X_test))\n",
    "print(\"Total number of transactions: \", len(X_train)+len(X_test))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(7619, 431)"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X_train.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/kuhung/anaconda2/lib/python2.7/site-packages/ipykernel/__main__.py:2: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
      "  from ipykernel import kernelapp as app\n"
     ]
    }
   ],
   "source": [
    "train=X_train\n",
    "train['label']=y_train\n",
    "\n",
    "train.to_csv('./input/train_feature.csv',index=False)\n",
    "train=pd.read_csv('./input/train_feature.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('Number of normal transactions: ', 1104)\n",
      "('Number of fraud transactions: ', 1104)\n",
      "('Total number of transactions in resampled data: ', 2208)\n"
     ]
    }
   ],
   "source": [
    "number_records_fraud = len(train[train.label != 0])\n",
    "fraud_indices = np.array(train[train.label != 0].index)\n",
    "\n",
    "# Picking the indices of the normal classes\n",
    "normal_indices = train[train.label == 0].index\n",
    "\n",
    "# Out of the indices we picked, randomly select \"x\" number (number_records_fraud)\n",
    "random_normal_indices = np.random.choice(normal_indices, number_records_fraud, replace = False)\n",
    "random_normal_indices = np.array(random_normal_indices)\n",
    "\n",
    "# Appending the 2 indices\n",
    "under_sample_indices = np.concatenate([fraud_indices,random_normal_indices])\n",
    "\n",
    "# Under sample dataset\n",
    "under_sample_data = train.iloc[under_sample_indices,:]\n",
    "\n",
    "X_undersample = under_sample_data.ix[:, under_sample_data.columns != 'label']\n",
    "y_undersample = under_sample_data.ix[:, under_sample_data.columns == 'label']\n",
    "\n",
    "# Showing ratio\n",
    "print(\"Number of normal transactions: \", len(under_sample_data[under_sample_data.label == 0]))\n",
    "print(\"Number of fraud transactions: \", len(under_sample_data[under_sample_data.label != 0]))\n",
    "print(\"Total number of transactions in resampled data: \", len(under_sample_data))\n",
    "\n",
    "# Oversample\n",
    "Oversampling1000 = train.loc[train.label == 1000]\n",
    "Oversampling1500 = train.loc[train.label == 1500]\n",
    "Oversampling2000 = train.loc[train.label == 2000]\n",
    "'''\n",
    "for i in range(6):\n",
    "    train = train.append(Oversampling1000)\n",
    "for j in range(10):\n",
    "    train = train.append(Oversampling1500)\n",
    "for k in range(12):\n",
    "    train = train.append(Oversampling2000)\n",
    "'''\n",
    "for i in range(5):\n",
    "    train = train.append(Oversampling1000)\n",
    "for j in range(8):\n",
    "    train = train.append(Oversampling1500)\n",
    "for k in range(10):\n",
    "    train = train.append(Oversampling2000)\n",
    "    \n",
    "train = train[train['label'].notnull()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(15394, 432)"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "('Number transactions train dataset: ', 1545)\n",
      "('Number transactions test dataset: ', 663)\n",
      "('Total number of transactions: ', 2208)\n"
     ]
    }
   ],
   "source": [
    "# Undersampled dataset\n",
    "X_train_undersample, X_test_undersample, y_train_undersample, y_test_undersample = train_test_split(X_undersample\n",
    "                                                                                                   ,y_undersample\n",
    "                                                                                                   ,test_size = 0.3\n",
    "                                                                                                   ,random_state = 2017)\n",
    "print(\"\")\n",
    "print(\"Number transactions train dataset: \", len(X_train_undersample))\n",
    "print(\"Number transactions test dataset: \", len(X_test_undersample))\n",
    "print(\"Total number of transactions: \", len(X_train_undersample)+len(X_test_undersample))\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def f1_macro(label_truth, predictions):\n",
    "    df=pd.DataFrame(columns=[\"subsidy_x\",\"subsidy_y\"])\n",
    "    df.subsidy_y=predictions\n",
    "    df.subsidy_x=np.array(label_truth)\n",
    "    df.subsidy_y = df.subsidy_y.apply(lambda x:int(x))\n",
    "\n",
    "    \n",
    "    correct = df[df['subsidy_x'] == df['subsidy_y']]\n",
    "    s = 0\n",
    "    for i in [1000, 1500, 2000]:\n",
    "        #print i\n",
    "        r = float(sum(correct['subsidy_y'] == i))/sum(df['subsidy_x'] == i)\n",
    "        #print r\n",
    "        p = float(sum(correct['subsidy_y'] == i))/sum(df['subsidy_y'] == i)        \n",
    "        #print p\n",
    "        f = r*p*2/(r+p)\n",
    "        if not np.isnan(f):\n",
    "            s += (float(sum(df['subsidy_x'] == i))/df.shape[0])*f\n",
    "    return s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import xgboost as xgb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "model=xgb.XGBClassifier()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "target = 'label'\n",
    "IDcol = 'id'\n",
    "ids = X_test['id'].values\n",
    "all_feature = [x for x in train.columns if x not in [target,IDcol]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "predictors=all_feature\n",
    "#predictors = [x for x in all_feature if (x in new_feature.index)]\n",
    "#predictors = [x for x in all_feature if (x in all_feature) & (x != 'id')]\n",
    "#predictors = [x for x in all_feature if x in all_feature]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.02921131464705735"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#model.fit(X_undersample[predictors],y_undersample[target])\n",
    "model.fit(train[predictors],train[target])\n",
    "prediction=model.predict(X_test[predictors])\n",
    "f1_macro(y_test,prediction)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def tuning_seed():\n",
    "\n",
    "    score=[]\n",
    "    for seed in (7,42,1996,2017,21,33):\n",
    "\n",
    "        X_train, X_test, y_train, y_test = train_test_split(X,y,test_size = 0.3, random_state = seed)\n",
    "    \n",
    "        train=X_train\n",
    "        train['label']=y_train\n",
    "    \n",
    "        Oversampling1000 = train.loc[train.label == 1000]\n",
    "        Oversampling1500 = train.loc[train.label == 1500]\n",
    "        Oversampling2000 = train.loc[train.label == 2000]\n",
    "\n",
    "        for i in range(5):\n",
    "            train = train.append(Oversampling1000)\n",
    "        for j in range(8):\n",
    "            train = train.append(Oversampling1500)\n",
    "        for k in range(10):\n",
    "            train = train.append(Oversampling2000)\n",
    "    \n",
    "    \n",
    "    \n",
    "        model.fit(train[predictors],train[target])\n",
    "        prediction=model.predict(X_test[predictors])\n",
    "        print seed,f1_macro(y_test,prediction)\n",
    "        score.append(f1_macro(y_test,prediction))\n",
    "    #print tuning_target,\n",
    "    print pd.DataFrame(score).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "70\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/kuhung/anaconda2/lib/python2.7/site-packages/ipykernel/__main__.py:9: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "7 0.0304187527847\n",
      "42 0.0318693666994\n",
      "1996 0.0291956208751\n",
      "2017 0.02824083306\n",
      "21 0.0334907585787\n",
      "33 0.0286655559336\n",
      "0    0.030313\n",
      "dtype: float64\n",
      "71\n",
      "7 0.0298707056933\n",
      "42 0.0319035368561\n",
      "1996 0.0308981815447\n",
      "2017 0.0282735720039\n",
      "21 0.0310838706901\n",
      "33 0.0282443959202\n",
      "0    0.030046\n",
      "dtype: float64\n"
     ]
    }
   ],
   "source": [
    "for feature_n in (70,71):\n",
    "    new_feature=feat_imp.head(feature_n)\n",
    "    predictors = [x for x in all_feature if (x in new_feature.index)]\n",
    "    \n",
    "    print feature_n\n",
    "    tuning_seed()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#feat_imp=pd.Series(model.booster().get_fscore()).sort_values(ascending=False)\n",
    "#feat_imp.plot(kind='bar', title='Feature Importances')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "new_feature=feat_imp.head(70)\n",
    "predictors = [x for x in all_feature if (x in new_feature.index)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index([    u'change_count',      u'price_sumH7',          u'countM8',\n",
       "           u'price_avgH17',         u'countH17',         u'地点21_avg',\n",
       "                u'countH8',      u'price_sumM9',        u'bathe_max',\n",
       "             u'rest_sumM9',         u'地点65_max',      u'price_avgH7',\n",
       "             u'rest_minM7',       u'rest_minM8',      u'bathe_count',\n",
       "           u'price_avgH7-',     u'total_people',         u'地点91_avg',\n",
       "           u'rank_percent',         u'地点72_sum',        u'bathe_sum',\n",
       "         u'price_medianH8',      u'price_maxH7',      u'price_maxH9',\n",
       "            u'price_sumM7',      u'price_maxM9',      u'price_sumM8',\n",
       "            u'library_min',      u'buban_count',      u'price_sumM3',\n",
       "            u'price_sumM1',       u'rest_sumM7',      u'price_maxWE',\n",
       "              u'price_min',        u'地点996_min',   u'rest_medianM11',\n",
       "           u'price_sumH19',         u'shop_avg', u'printhouse_count',\n",
       "                   u'rank',     u'price_sumM11',        u'地点996_sum',\n",
       "            u'price_minM3',        u'地点996_max',  u'price_medianM12',\n",
       "        u'price_medianH19',         u'dean_avg',       u'rest_minM6',\n",
       "          u'price_avgH19+',       u'rest_avgM1',        u'地点263_avg',\n",
       "            u'rest_maxM12',          u'countWE',      u'地点213_count',\n",
       "             u'rest_minM2',      u'rest_minM10',    u'rest_medianH7',\n",
       "            u'price_maxM6',   u'price_medianM9',        u'other_avg',\n",
       "          u'rest_medianM7',   u'library_median',         u'rest_min',\n",
       "             u'rest_minH9',      u'rest_maxM11',       u'rest_avgM8',\n",
       "            u'rest_avgM10',       u'rest_avgH7',     u'price_maxH18',\n",
       "                u'countM7'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_feature.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#new_feature.to_csv('input/big_nice_feature.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "370"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "feat_imp.count()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# -*- coding: utf-8 -*- "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "new_feature=pd.DataFrame(data=new_feature.index)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "new_feature=np.array(new_feature)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "new_feature=pd.DataFrame(data=new_feature)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0         change_count\n",
      "1          price_sumH7\n",
      "2              countM8\n",
      "3         price_avgH17\n",
      "4             countH17\n",
      "5             地点21_avg\n",
      "6              countH8\n",
      "7          price_sumM9\n",
      "8            bathe_max\n",
      "9           rest_sumM9\n",
      "10            地点65_max\n",
      "11         price_avgH7\n",
      "12          rest_minM7\n",
      "13          rest_minM8\n",
      "14         bathe_count\n",
      "15        price_avgH7-\n",
      "16        total_people\n",
      "17            地点91_avg\n",
      "18        rank_percent\n",
      "19            地点72_sum\n",
      "20           bathe_sum\n",
      "21      price_medianH8\n",
      "22         price_maxH7\n",
      "23         price_maxH9\n",
      "24         price_sumM7\n",
      "25         price_maxM9\n",
      "26         price_sumM8\n",
      "27         library_min\n",
      "28         buban_count\n",
      "29         price_sumM3\n",
      "30         price_sumM1\n",
      "31          rest_sumM7\n",
      "32         price_maxWE\n",
      "33           price_min\n",
      "34           地点996_min\n",
      "35      rest_medianM11\n",
      "36        price_sumH19\n",
      "37            shop_avg\n",
      "38    printhouse_count\n",
      "39                rank\n",
      "Name: 0, dtype: object\n"
     ]
    }
   ],
   "source": [
    "print new_feature[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [Root]",
   "language": "python",
   "name": "Python [Root]"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
